﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;

namespace GiveGraphModel
{
    public class ServiceResponse
    {


        public virtual Member User { get; set; }

        public virtual ServiceRequest Request { get; set; }

        public virtual Service Service { get; set; }



        internal int UserId { get; set; }

        internal int RequestId { get; set; }
        internal int ServiceId { get; set; }

    }

    public sealed class ServiceResponseConfiguration : EntityTypeConfiguration<ServiceResponse>
    {
        public ServiceResponseConfiguration()
        {
            HasKey(sr => new { sr.RequestId, sr.ServiceId, sr.UserId });

            HasRequired(sr => sr.User)
                .WithMany()
                .HasForeignKey(sr => sr.UserId)
                .WillCascadeOnDelete(false);

            HasRequired(sr => sr.Service)
                .WithMany()
                .HasForeignKey(sr => sr.ServiceId)
                .WillCascadeOnDelete(false);

            HasRequired(sr => sr.Request)
                .WithMany()
                .HasForeignKey(sr => sr.RequestId)
                .WillCascadeOnDelete(false);
        }
    }

}


